<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>对象变更检测</title>
</head>
<body>
    <div id="app">
        {{user.name}},{{user.age}},{{user.phone}}
    </br>
        <button @click='handlerAdd'>添加属性</button>
    </div>
    <script src="vue.js"></script>
    <script>
        new Vue({
            el:'#app',
            data:{
                user:{}
            },
            methods:{
                handlerAdd(){
                    // 添加一个属性
                    // this.$set(this.user,'age',20)
                    // 添加多个属性
                    this.user=Object.assign({},this.user,{
                        age:20,
                        phone:18387837264
                    })
                }
            },
            created(){
                setTimeout(()=>{
                    this.user={
                        name:'张三'
                    }
                },1250)
            }
        })
    </script>
</body>
</html>